package com.aita.diamond;

import com.gd.card.mgnt.CardUser
import com.gd.domain.party.Operator
import com.gd.domain.party.Organization
import com.gd.loyalty.gift.Gift
import com.gd.magic.Column
import com.gd.card.mgnt.Customer

//订购/销售单
class Order extends com.gd.magic.RootEntity  {
	static int idLength = 8
	
	Organization org			//所属机构
	Operator salesoper			//销售人员
	VIPCustomer customer          //客户
	@Column (dict="orderType",notNull=true)
	int orderType				//类型 订单(无现货 )销售单(有现货)
	@Column (dict="orderStatus",notNull=true)
	int orderStatus				//状态:订单：新建-已提交（新建）-定制中-定制完成-售出   销售单：售出
	      

	long amount					//价格
	long earnest				//定金
	
	@Column (index=true)
	Date occurTime				//时间
	
	String comments  //备注
	
	
	public void preUpdate(boolean isNew) {
		if (isNew) {
			if (!org)
				org = loginService.currentOrg()
			if(!salesoper)
				salesoper = loginService.currentOperator()
			if(!occurTime)
				occurTime = new Date();
		}
		
		super.preUpdate(isNew)
	}
}